﻿/*
 * StatePresenter support following states:
 * 
 * 1.Busy
 * 2.Message
 * 3.Enable or Disable content
 * 
 */

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace SNSpirit.Controls
{
    public delegate void StateChangePresentRoutedEventHandler(object sender, StateChangePresentRoutedEventArgs e);

    public class StateChangePresentRoutedEventArgs : RoutedEventArgs
    {
        public StateChangePresentRoutedEventArgs() : base() { }
        public StateChangePresentRoutedEventArgs(RoutedEvent routedEvent) : base(routedEvent) { }
        public StateChangePresentRoutedEventArgs(RoutedEvent routedEvent, object source) : base(routedEvent, source) { }


    }

    public class StatePresenter : Border
    {
        static StatePresenter()
        {
            DefaultStyleKeyProperty.OverrideMetadata(typeof(StatePresenter), new FrameworkPropertyMetadata(typeof(StatePresenter)));
        }

        public static readonly RoutedEvent StateChangePresentEvent = EventManager.RegisterRoutedEvent("StateChangePresent", RoutingStrategy.Bubble, typeof(StateChangePresentRoutedEventHandler), typeof(StatePresenter));

        public static void RaiseStateChangePresentEvent(IInputElement inputElement, IEnumerable<State> states)
        {
            if (inputElement == null)
                throw new ArgumentNullException("inputElement");
            if (states != null && states.Count() != 0)
            {
                inputElement.RaiseEvent(new StateChangePresentRoutedEventArgs(StatePresenter.StateChangePresentEvent, inputElement));
            }
        }
    }
}
